package com.example.administrator.teainfo.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.List;

/**
 * Created by Administrator on 2016/12/11.
 */

public class HeadNewsAdapter extends PagerAdapter {
    private List<ImageView> list;
    public  HeadNewsAdapter(List<ImageView> list){
        this.list = list;
    }
    @Override
    public int getCount() {
        return list==null?0:list.size();
    }

    @Override
    public View instantiateItem(ViewGroup container, int position) {
        View ret;
        ret = list.get(position);
        return ret;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        super.destroyItem(container, position, object);
        if (object instanceof View) {
            View view = (View) object;
            container.removeView(view);
        }
    }
}
